import { request } from 'umi';

/** 获取马达报警记录 GET /api/log */
export async function queryDeviceAlarm(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
     /** 设备id */
    deviceId?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/deviceAlarmRecord', {
  
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}


/** 获取马达报警记录 GET /api/log */
export async function queryDeviceAlarmNotices(
  params: {
 
    /** 页面的容量 */
    size?: number;
  },
  options?: { [key: string]: any },
) {
  return request<Record<string, any>>('/api/queryDeviceAlarmNotices', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

// 首页统计高中低报警数量
export async function queryDeviceCount() {
  return request<API.RequestData>('/api/queryDeviceCount', {
    method: 'POST',
  });
}


/** 更新报警记录 PUT /api/alarm/handle */
export async function updateDeviceAlarm(body: API.AlarmRulesItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/handle', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}



/** 删除报警记录 DELETE /api/deviceAlarmRecord/batchdel */
export async function removeDeviceAlarm(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/record', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}


/** 删除报警记录 DELETE /api/deviceAlarmRecord/batchdel */
export async function batchRemoveDeviceAlarm(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/record/batchdel', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}



// 报警分析页数据
export async function queryAlarmAnalysis() {
  return request<API.RequestData>('/api/alarm/analysis', {
    method: 'GET',
  });
}
//  报警分析页 按年月日筛选
export async function queryAlarmAnalysisByType(params) {
  return request<API.RequestData>('/api/alarm/analysisByType', {
    method: 'GET',
    params: {
      ...params,
    },
  });
}

/** 批量处置 */
export async function batchHandle(body: object, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/alarm/batchHandle', {
    method: 'PUT',
    requestType: 'form',
    data: body,
    ...(options || {}),
  });
}
